package com.lskj.shiro.util;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import java.util.concurrent.TimeUnit;

/**
 * @Author zzq
 * @Date 2020/3/31 15:57
 * @Version 1.0
 */
@Component
public class RedisUtil {

    private static Logger logger = LoggerFactory.getLogger(RedisUtil.class);
    @Autowired
    private RedisTemplate<Object, Object> redisTemplate;

    public Object get(Object key) {
        return redisTemplate.opsForValue().get(key);

    }

    public void set(Object key, Object value) {
        redisTemplate.opsForValue().set(key, value);
    }

    public boolean expire(Object key, long timeout) {
        return redisTemplate.expire(key, timeout, TimeUnit.SECONDS);
    }
}
